<%@ page import="com.xinjie.www.service.comment.CommentServiceImpl" %>
<%@ page import="com.xinjie.www.po.Comment" %>
<%@ page import="java.util.List" %>
<%@ page import="java.sql.SQLException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>评论</title>
    <style type="text/css">
        table {
            width: 100%;
            border: 1px solid red;
            border-collapse: collapse;
        }

        th, td {
            border: 1px solid red;
        }
    </style>
</head>
<body>
<%
    CommentServiceImpl commentService = new CommentServiceImpl();
    int post = Integer.parseInt(request.getParameter("post"));
    String s = request.getParameter("tieba");
    List<Comment> comments = null;
    try {
        comments = commentService.getComment(post);
    } catch (SQLException | ClassNotFoundException e) {
        e.printStackTrace();
    }
%>
<div align="center">
    <table>
        <tr>
            <th>评论id</th>
            <th>评论人id</th>
            <th>评论内容</th>
            <th>评论时间</th>
        </tr>
        <%
            for (Comment comment : comments) {
        %>
        <tr>
            <%="<td>" + comment.getCommentId() + "</td>"%>
            <%="<td>" + comment.getUserId() + "</td>"%>
            <%="<td>" + comment.getContent() + "</td>"%>
            <%="<td>" + comment.getTime() + "</td>"%>
        </tr>
        <%}%>
    </table>
    <a href="PostList.jsp?tieba=<%=s%>">返回</a>
</div>
</body>
</html>
